import { ipcMain } from 'electron'
import ipcEventChannels from '../../common/ipcEventChannels'
import store from '../store'

export default () => {
    ipcMain.handle(ipcEventChannels.STORE_GET_ALL_SETTINGS, () => store.getAllSettings())
    ipcMain.handle(ipcEventChannels.STORE_GET_SETTINGS, (_, key) => {
        return store.getSetting(key)
    })
    ipcMain.on(ipcEventChannels.STORE_SET_SETTINGS, (_, key, value) => {
        store.setSetting(key, value)
    })

    ipcMain.handle(ipcEventChannels.STORE_GET_CHATLIST, () => {
        return store.getChatlist()
    })
    ipcMain.on(ipcEventChannels.STORE_SET_SETTINGS, (_, value) => {
        store.setChatlist(value)
    })
}
